package resources.dao;

import resources.pojo.account;

public class AccountDAO extends DatabaseDAO{
	public static account checkLogin(account account){
		account acc = null;
		String sql = "call sp_login(?,?)";
		try {
			getDBPoolConnection();
			conn.setAutoCommit(false);
			cs = conn.prepareCall(sql);
			cs.setString(1,account.getUsername());
			cs.setString(2, account.getPassword());
			rs = cs.executeQuery();
			conn.commit();
			while(rs.next()){
				acc = new account();
				acc.setUsername(rs.getString("a.username"));
			}
		} catch (Exception e) {
			try {
				conn.rollback();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			e.printStackTrace();
			return null;
		} finally{
			closeConnection();
		}
		return acc;
	}
}
